package com.qf.domain;

import java.util.List;

/**
 * @author Administrator
 * @version v1.0
 * @date 2022/4/21
 */
public class GtPageBean<T> {
    private int pageSize;//页大小，每页显示条数
    private int pageNum;//页码 当前页
    private long totalSize;//总数据量
    private int pageCount;//总页数
    private List<T> data;//当前页分页数据

    private int startPage;//起始页
    private int endPage;//结束页面

    public GtPageBean() {
    }

    public GtPageBean(int pageSize, int pageNum, long totalSize, List<T> data) {
        this.pageSize = pageSize;
        this.pageNum = pageNum;
        this.totalSize = totalSize;
        this.data = data;

        //计算总页数
        this.pageCount = (int)(totalSize%pageSize==0?totalSize/pageSize:totalSize/pageSize+1);

        this.startPage=pageNum-4;
        this.endPage=pageNum+5;

        if(pageNum<=5){
            this.startPage=1;
            this.endPage=10;
        }

        if(this.pageNum>this.pageCount-5){
            this.startPage=this.pageCount-9;
            this.endPage=this.pageCount;
        }
        if(this.pageCount<=10){
            this.startPage=1;
            this.endPage=this.pageCount;
        }

    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public long getTotalSize() {
        return totalSize;
    }

    public void setTotalSize(long totalSize) {
        this.totalSize = totalSize;
    }

    public int getPageCount() {
        return pageCount;
    }

    public void setPageCount(int pageCount) {
        this.pageCount = pageCount;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public int getStartPage() {
        return startPage;
    }

    public void setStartPage(int startPage) {
        this.startPage = startPage;
    }

    public int getEndPage() {
        return endPage;
    }

    public void setEndPage(int endPage) {
        this.endPage = endPage;
    }

    @Override
    public String toString() {
        return "PageBean{" +
                "pageSize=" + pageSize +
                ", pageNum=" + pageNum +
                ", totalSize=" + totalSize +
                ", pageCount=" + pageCount +
                ", data=" + data +
                ", startPage=" + startPage +
                ", endPage=" + endPage +
                '}';
    }
}